{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import holoviews as hv\n",
    "from holoviews.streams import Pipe, Buffer\n",
    "import pandas as pd\n",
    "class real_time_plot:\n",
    "    def __init__(self, plot_len):\n",
    "        hv.extension('bokeh')\n",
    "        st = pd.DataFrame({'y':[]}, columns=['y'])\n",
    "        self.dfstream = Buffer(st, length=plot_len, index=False)\n",
    "        curve_dmap = hv.DynamicMap(hv.Curve, streams=[self.dfstream])\n",
    "        curve_dmap.opts(width=800, height=600)\n",
    "        display(curve_dmap)\n",
    "    def send(self, data):\n",
    "        if hasattr(data, 'wave'):\n",
    "            d = data.wave\n",
    "        else:\n",
    "            d = data\n",
    "        self.dfstream.send(pd.DataFrame({'y':d}))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
